package com.hnkywl.sts.service.report;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.hnkywl.sts.dao.report.CwsfcDao;
import com.hnkywl.sts.dao.report.WlycwsfcDao;
import net.ruixin.orm.hibernate.Page;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-6-14
 * Time: 下午4:50
 * To change this template use File | Settings | File Templates.
 */
@Service
public class WlycwsfcService {
    private WlycwsfcDao wlycwsfcDao;

    /**
     * 财务收发存报表
     *
     * @param gsid
     * @param year
     * @param month
     * @return
     */
    public String wlyCwsfcList(Long gsid, Integer year, Integer month) {
        Map<String, List> result = wlycwsfcDao.wlyCwsfcList(gsid, year, month);
        List<Map> rows = result.get("rows");
        List<Map> footer = result.get("footer");
        Gson gson = new GsonBuilder().create();
        String rowsJson = gson.toJson(rows);
        String footerJson = gson.toJson(footer);
        String json = "{\"rows\":" + rowsJson + ",\"footer\":" + footerJson + "}";
        return json;
    }

    public String cbjz(Integer year, Integer month) {
        return wlycwsfcDao.cbjz(year, month);
    }



    @Autowired
    public void setWlycwsfcDao(WlycwsfcDao wlycwsfcDao) {
        this.wlycwsfcDao = wlycwsfcDao;
    }
}
